package com.sx.first.biz;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.sx.first.biz.ProductBiz;
import com.sx.first.dao.ProductDAO;
import com.sx.first.model.Product;

@Service("productBiz")
@Scope("prototype")
public class ProductBiz {
	private ProductDAO productDAO;
	
	public void setProductDAO(ProductDAO productDAO) {
		this.productDAO = productDAO;
	}

	public List<Product> findAll(){
		return productDAO.findAll();
	}

	public void save(Product pro) {
		productDAO.save(pro);
		
	}

	public Product findById(int proId) {
		return productDAO.findById(proId);
	}

	public void delete(int proId) {
		productDAO.delete(productDAO.findById(proId));
		
	}

	public void update(Product pro) {
		productDAO.update(pro);
		
	}

	public List<Product> findAllByMatId(int matId) {
		return productDAO.findAllByMatId(matId);
	}
	

}
